#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int repeatedNTimes(vector<int>& nums) {
        int n = nums.size();
        unordered_map<int, int> vis;

        for (int i = 0; i < n; i++)
            vis[nums[i]] += 1;
        for (int i = 0; i < n; i++)
            if (vis[nums[i]] == n / 2)
                return nums[i];
        return -1;
    }
};
